﻿<!--#include file="../lib/base.asp"-->
<!--#include file="../theme.asp"-->
<%
	sdcms.checkuserlogin
	dim act:act=lcase(sdcms.fget("act",0))
	select case act
		case "db":checkdb()
		case else
			sdcms.show theme_userpay,""
	end select
	
	sub checkdb()
		dim t0,t1,t2,t3
		t0=sdcms.getint(sdcms.fget("t0",0),0)
		t1=sdcms.enhtml(sdcms.fget("t1",0))
		t2=sdcms.enhtml(sdcms.fget("t2",0))
		t3="../api/pay/{payway}/api.asp?"
		if t0<=0 then
			sdcms.script("alert(""至少需要充值1元，请重新输入充值金额"")")
			sdcms.script("window.close()")
			exit sub
		end if
		if sdcms.strlen(t1)<=0 then
			sdcms.script("alert(""支付方式选择错误，请重新选择"")")
			sdcms.script("window.close()")
			exit sub
		end if
		t3=replace(t3,"{payway}",t1)
		dim orderid
		orderid=sdcms.getrndfilename
		dim userdata:userdata=sdcms.userinfo
		sdcms.db.insert "sd_user_payrecord",array(array("orderid",orderid,50,1),array("amount",t0,10,0),array("payway",t2,10,1),array("userid",userdata(0),0,0),array("isover",0,2,0),array("createdate",sqltime,50,0))
		sdcms.go t3&"t0="&orderid&"&t1="&t0
	end sub
	sdcms.db.dbclose
%>